<?php
namespace app\modules\film\models;


use app\common\base\ApiModel;
use app\modules\film\service\TypeOfFilmService;
use app\modules\user\behaviors\TimestampBehavior;

class Film extends ApiModel{

    public static function tableName(){
        return 'film_basic';
    }

    // public function behaviors()
    // {
    //     return [
    //         [
    //             'class' => TimestampBehavior::class,
    //         ]
    //     ];
    // }

    public function rules()
    {
        return [
            [['film_name', 'film_length'], 'required'],
            [['film_recommend', 'film_box_office', 'film_actor'], 'string'],
            [['status', 'is_on_show'], 'integer'],
            ['status', 'default', 'value' => 1],
            ['is_on_show', 'default', 'value' => 0],

        ];
    }

    public function getFilmType(){
        return $this->hasMany(TypeOfFilm::class,['film_id' => 'id'])->with(['filmType']);
    }

    // public function fields()
    // {
    //     $fields = parent::fields();
    //     $filmType = [];
    //     print_r($fields);die;
    //     if(isset($fields['filmType'])){
    //         foreach($fields['filmType'] as $one){
    //             $filmType[] = $one['type_name'];
    //         }
    //     }
    // }


}